//
//  OSSpinLockDemo.m
//  iOSLock
//
//  Created by 崔博 on 2018/7/24.
//  Copyright © 2018年 崔博. All rights reserved.
//

#import "OSSpinLockDemo.h"
#import <libkern/OSAtomic.h>

@interface OSSpinLockDemo()
@property (nonatomic, assign) OSSpinLock moenyLock;
@property (nonatomic, assign) OSSpinLock ticketLock;
@end
@implementation OSSpinLockDemo

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.moenyLock = OS_SPINLOCK_INIT;
        self.ticketLock = OS_SPINLOCK_INIT;
    }
    return self;
}

- (void)__saleTickets
{
    OSSpinLockLock(&_moenyLock);
    [super __saleTickets];
    OSSpinLockUnlock(&_moenyLock);
}
- (void)__drawMoney
{
    OSSpinLockLock(&_moenyLock);
    [super __drawMoney];
    OSSpinLockUnlock(&_moenyLock);
}
- (void)__saveMoney
{
    OSSpinLockLock(&_moenyLock);
    [super __saveMoney];
    OSSpinLockUnlock(&_moenyLock);

}
@end
